Finally, Standards!

Standard ECMA-262 promises to tidy up the differences between JavaScript and JScript! Does it?

Discussion

In June, 1997, the ECMA (European Computer Manufacturers Association) General Assembly adopted a standard for a "general purpose scripting language" called ECMAScript, also known as Standard ECMA-262. You and we are more likely to call it "JavaScript." At first reading, the ECMA standard follows the path laid out by Netscape for JavaScript in in every fundamental respect (which leaves IE 3.x JScript somewhat lacking; some critics have labeled ECMA-262 a "rubberstamping" of Netscape's JavaScript specification). JavaScript code written for Netscape Communicator 4.0x should run without incident or surprises on an ECMAScript-compliant browser.

ECMA-262 lays out a standard, but leaves room for what we'll call "differences of opinion" among browser manufacturers as to what constitutes a conformant browser. Here is item 2 from the standard:

2 Conformance

  • A conforming implementation of ECMAScript must provide and support all the types, values, objects, properties, functions, and program syntax described in this specification.
  • A conforming implementation of ECMAScript is permitted to provide additional types, values, objects, properties, and functions beyond those described in this specification. In particular, a conforming implementation of ECMAScript is permitted to provide properties not described in this specification, and values for those properties, for objects that are described in this specification.
  • A conforming implementation of ECMAScript is permitted to support program syntax not described in this specification. In particular, a conforming implementation of ECMAScript is permitted to support program syntax that makes use of the "future reserved words" listed in section 0 of this specification.

That's a mouthful, isn't it? It seems to us that this dilutes the standard somewhat, since it means that any given browser manufacturer can still add all sorts of new "gee-whiz" features to its version of JavaScript, and effectively deny you any real use of those features on the broad Web because you can't depend on all the possible end-users having the browser version supporting those features. In other words, just knowing that the browser is "ECMA-262 compliant" isn't enough.

Still, it's a start.

Microsoft has publicly promised to comply with the standard beginning with Internet Explorer 4.0. The launch of IE 4.0 has proved that promise to be kept in the broadest sense, although it's hard to tell since Netscape has added features in Communicator that don't appear to be in IE. Perhaps because of this Microsoft now claims that Communicator's JavaScript engine isn't EMCA-262 compliant!

The ECMA-262 specification lays out fundamental aspects of the language, but shies away from browser environment issues. It doesn't address, for example, what interface a compliant engine might be expected to handle. At first this seems to a grave omission, because it's user events which are the most interesting and dynamic part of scripting. The HTML 3.2 specification published by the W3 Consortium (W3C) is silent on the topic as well, so that leaves us as developers in limbo as to what events we can expect an ECMA-262 compliant browser to handle.

One more interesting omission involves the do...while() looping construct, which is not mentioned in ECMA-262, but supported by Netscape Communicator. As much as you might want to use it, you'll probably be better off with a simple while() loop.

Conclusion: as of the time we write this, you're still in the business of worrying about what browser is "at the other end." The ECMA-262 initiative is a good start, however, toward the day when you can get out of that business and just concentrate on writing good and useful scripts for your Web pages. In the meantime, if you write scripts that use only ECMA-262 compliant language constructs and objects, and only use events found in Netscape Navigator 3.2 and later (even if the audience is Internet Explorer 4.0), the maximum number of users possible should be able to enjoy your JavaScripted web pages.

Copyright ©1998 by Charles River Media, All Rights Reserved